home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
050
/
list.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1985-03-15
|
4KB
|
161 lines
PROGRAM LIST; {12/27/84}
{ Compile with TURBO PASCAL.
LIST - Program source code listing utility.
Will format and print standard ASCII files:
-Allows up to 20 files to be specified to be printed batch style.
-Paginates (standard 8 1/2 X 11 paper, 80-column printer).
-Correct pagination even if some lines exceed right margin and printer
"wraps" to next line.
-Allows you to specify a left margin (default is 5), so listing can
be inserted in loose-leaf binder.
-Prints header with file name and page number.
-Allows additional text in header, such as date, name, etc..
Usage:
Have printer ready, then type LIST <Enter> at DOS prompt and respond
to prompts in program. Accepts drive designator for non-default drive,
but not DOS pathnames. Begins printing immediately after optional
header text is entered.
Author:
Frank L. Eskridge
2895 Hill Park Court
Marietta, GA 30062
(404) 973-1714 }
TYPE namestring=STRING[12];
VAR
input_file :TEXT;
filename :ARRAY [1..20] OF NAMESTRING;
header :STRING[50];
line :STRING[255];
header_length,
offset,i,c :INTEGER;
ok :BOOLEAN;
PROCEDURE SPACE(number:INTEGER);
VAR x : INTEGER;
BEGIN
FOR x := 1 TO number DO
WRITE(lst,' ');
END;
PROCEDURE LINE_FEED;
BEGIN
WRITELN(lst,'');
END;
PROCEDURE CONVERT_TO_UPPER(VAR allcaps:namestring);
VAR x :INTEGER;
ch :CHAR;
newword :NAMESTRING;
BEGIN
newword := '';
FOR x := 1 TO LENGTH(allcaps) DO
BEGIN
ch := allcaps[x];
newword := newword + upcase(ch);
END;
allcaps := newword;
END;
PROCEDURE GET_FILENAMES;
VAR ch :CHAR;
BEGIN
i := 1;
REPEAT
WRITE('Name of file to list on printer (CR to end): ');
READLN(filename[i]);
CONVERT_TO_UPPER(filename[i]);
i := i+1;
UNTIL filename[i-1] = '';
END;
PROCEDURE GET_OFFSET;
VAR cnum: STRING[2];
code: INTEGER;
BEGIN
REPEAT
WRITE('Number of columns to offset left margin [5]: ');
READLN(cnum);
IF cnum = ''THEN cnum:='5';
VAL(cnum,offset,code);
IF (offset<0) OR (offset>50) THEN
WRITELN(#7+'Please enter a number between 0 and 50...');
UNTIL (offset>=0) AND (offset<51);
END;
PROCEDURE GET_HEADER;
BEGIN
WRITE('Enter header or date, if any: ');
READLN(header);
END;
PROCEDURE OPEN(name:namestring);
BEGIN
ASSIGN(input_file,filename[c]);
{$I-}RESET(input_file) {$I+};
ok := (IOResult=0);
IF NOT ok THEN WRITELN(#7+' ----> Invalid filename--ignoring.');
END;
PROCEDURE PRINT_FILE(name:namestring);
VAR page,ln : INTEGER;
BEGIN
page := 1;
header_length := LENGTH(filename[c])+LENGTH(header)+offset+2;
WHILE NOT EOF(input_file) DO
BEGIN
SPACE(offset);
WRITE(lst,filename[c]+' '+header);
SPACE(65-header_length);
WRITE(lst,'Page');
WRITELN(lst,page:3);
LINE_FEED;LINE_FEED;
LN := 5;
WHILE (LN < 60) AND (NOT EOF(input_file)) DO
BEGIN
READLN(input_file,line);
SPACE(offset);
WRITELN(lst,line);
IF LENGTH(line) > 80-offset THEN LN := LN+1;
LN := LN+1;
END;
WRITE(lst,^L);
page := page + 1;
END;
END;
BEGIN {main program}
WRITELN('LIST -- Formats and prints up to 20 ASCII files.');
WRITELN('-------------------------------------------------');
GET_FILENAMES;
GET_OFFSET;
GET_HEADER;
WRITELN;
FOR c := 1 TO (i-2) DO
BEGIN
WRITE('Printing ---> '+filename[c]);
OPEN(filename[c]);
IF ok THEN
BEGIN
PRINT_FILE(filename[c]);
CLOSE(input_file);
WRITELN(' ----> Done');
END;
END;
END.